1. Field of the Invention
The present invention relates to an image processing method for synthesizing a second image real timely generated in a first image generated in advance, such as a background image, during game or simulation progression, and more particularly, to an image processing method and a storage medium for storing an image processing programs whereby a more realistic image can be generated by giving operators an impression of depth to the first image without increasing times of calculation.
2. Description of the Related Art
Image processing technology for synthesizing an image of object generated in real time in a pre-generated background image is widely used in simulation devices and game devices. The pre-generated image means a non-moving picture or moving picture generated by a computer graphics technique, movie picture, an image generated by animation or the like, for example. Since it takes much time to calculate for generating these images in real time by a computer, a pre-generated static or frame image is recorded and employed as a texture of background polygon.
That will be now explained in an example of computer graphics. For generating a background image in advance, a background picture is modeled by employing a computer, and the modeled data is subject to a rendering process so as to generate color data in each pixel of static picture, at first. The color data is recorded in a texture buffer of an image processing device as texture data, and the texture data recorded in the texture buffer is drawn as color data for the background polygon, which is one of plain polygons. A background image including plural objects, such as buildings, trees, or mountains, can be treated as one polygon, thus it makes possible to reduce the calculation time extensively.
However, in the above-described method, when synthesizing objects, which move in real time, to the background image, the objects are synthesized on the background image. Therefore, the synthesized image lacks the impression of depth and distance.
FIGS. 1A to 1D are explanatory diagrams of the above-described conventional problems of synthesized image. FIG. 1A shows an example of pre-generated background image. In the example, two buildings B1 and B2 are arranged along a depth direction in a display screen. FIG. 1B shows an example of image of real timely generated object. In FIG. 1B, a building B3, which is slightly on a right side from a center, is placed between the buildings B1 and B2. FIG. 1C shows an image obtained by synthesizing the background image shown in FIG. 1A and the image of object shown in FIG. 1B according to the conventional method.
Since the background image is processed as one plain polygon according to the conventional method, there is no depth in screen in the image. Therefore, in the conventional method, the real timely generated object B3 including a depth value (Z value) is simply synthesized on the background image. Then, the conventional synthesized image shown in FIG. 1C has no impression of depth, and therefore, the building B3 is positioned in front of the building B1, thus the synthesized image is much different from a real image.
Therefore, it is an object of the present invention to provide an image processing method wherein the real timely generated object B3 can be synchronized between the buildings B1 and B2 in the background image, as shown by a synthesized image in FIG. 1D.
It is possible to imitatively generate a synthesized image as shown in FIG. 1D by processing the objects B1 and B2 in the background image, each having a different depth value, as different plain polygons, even in the conventional method. However, the use of conventional method means that all of plural objects in the background image are processed by different plain polygons, such process results in a longer computer calculation time, and therefore, the conventional method can not be used because it is not suitable for a real time image processing. The present invention rigidly has a condition that calculation times for the background image are reduced by treating the background image as one or few plain polygons. The object of the present invention is to give an impression of distance to the synthesized image, when the real timely generated object is synthesized to the background image under such condition.
FIG. 2 shows an explanation diagram of the conventional problem of the synthesized image. In the example of FIG. 2, a wall W1 is foremost, a wall 2 is rearmost, and a wall W3, which extends along a depth direction connecting to these walls W1 and W2, is further arranged in a display screen 10. A tunnel T1 is formed on the wall W3. In the above-described conventional method, it is impossible to generate a synthesized image such that a real timely synthesized movable object OB1, such as a car, enters the tunnel T1 on the wall W3. In other words, it is impossible to generate an image such that the polygon of the other object enters into a plain polygon (W3), if the background image W3 is treated as one plain polygon and a uniform depth value, e.g., an infinite value, is given to the plain polygon. Additionally, even if the walls W1, W2 and W3 are processed in respective plain polygons, it is impossible to synthesize the real timely generated object OB1 entered in the wall W3, if the uniform depth value is given to the plain polygon for the wall W3.
Therefore, it is an object of the present invention to provide an image processing method wherein it is possible to synthesize such that a real timely generated object OB1 is entered in a background image formed of walls W1, W2, W3, and a tunnel T1, as shown in FIG. 2.
It is another object of the present invention to provide an image processing method wherein when synthesizing a real timely generated image in a pre-generated image, the image can be synthesized to the pre-generated image with giving an impression of depth, without increasing loads to image processing, and to provide a storage medium storing the image processing program.
It is a still further object of the present invention to provide an image processing method wherein when synthesizing a real timely generated image in a pre-generated image, the real timely generated image can be synthesized as entering at a certain portion along a depth direction in the pre-generated image, without increasing loads to image processing, and to provide a storage medium storing the image processing program.
It is a furthermore object of the present invention to provide an image processing method wherein a pre-generated image is arranged on an optional position in a screen, and further, a real timely generated image can be synthesized in the screen with giving an impression of distance or as the image enters at a certain position along a depth direction in the pre-generated image, and to provide a storage medium storing the image processing program.
To achieve the above-described objects, in the present invention, image data of a pre-generated image, such as a background image, includes image data, which is texture data or color data, and Z data indicating a depth in a screen. Then, the data of the pre-generated image like a background image is recorded on a storage medium in advance. The Z data of real timely generated image is compared with the Z data of the background image, and the image data, which is foremost in the screen, is written in a frame buffer. It becomes possible to synthesize the image of real timely generated object in the background image with giving an impression of depth or distance by adding the Z data to the data of pre-generated image.
To achieve the above-described objects, in the present invention, an image processing method for synthesizing a pre-generated first image with a real-timely generated second image, wherein texture data and texture Z data indicating a depth in a screen are pre-generated in a predetermined pixel unit as data of the first image, comprising a step of: recording in a frame buffer data of the first image or the second image which is foremost in the screen, according to the Z data indicating a depth in the screen of the second image and the texture Z data at a corresponding pixel position in the screen.
According to the above-described invention, it becomes possible to synthesize the real-timely generated second image in the first image with giving an impression of depth or distance by including the Z data in the data of first image, such as a background image.
To achieve the above-described objects, in the present invention, an image processing method for synthesizing a pre-generated first image with a real-timely generated second image, in which a Z buffer for recording Z data indicating a depth in a screen of an image to be displayed is used, and Z data of an image to be processed is compared with Z data stored in the Z buffer so as to record the image data to be processed, which is foremost in the screen in a frame buffer, comprising the steps of:
(a) recording data of the pre-generated first image having first image data and first Z data indicating a depth in the screen in each predetermined pixel unit in a first buffer;
(b) comparing the Z data stored in the Z buffer with the first Z data stored in the first buffer and drawing the first image data stored in the first buffer at a predetermined position in the frame buffer, when the first image is foremost in the screen; and
(c) comparing the Z data stored in the Z buffer with a second Z data of the second image and drawing a second image data of the second image at a predetermined position in the frame buffer, when the second image is foremost in the screen.
According to the present invention, since data of the pre-generated image, such as a background image, is recorded in the first buffer first, a desired portion of the pre-generated image can be recorded in the frame buffer with a desired size. Additionally, the image data of the second image, which is foremost in the screen, can be written in the frame buffer by comparing the Z data of the written image with the Z data of the real-timely generated second image. Therefore, it can be realized to synthesize the second image in the first image with giving an impression of depth. Either the above-described steps (b) or (c) may be executed first.
To achieve the above-described objects, in the present invention, an image processing method for synthesizing a pre-generated first image with a real-timely generated second image, in which a Z buffer for recording Z data indicating a depth in a screen of image to be displayed is used, and the Z data of pixel to be processed is compared with the Z data recorded in the Z buffer so as to record the image data, which is foremost in the screen, in a frame buffer, comprising the steps of:
(a) recording data of the pre-generated first image having texture data and texture Z data indicating a depth in the screen in each predetermined pixel unit in a texture buffer;
(b) comparing the Z data recorded in the Z buffer with the Z data of the first image generated from the texture Z data, in response to an instruction of drawing the first image, and recording the first image data generated from the texture data in the frame buffer, when the pixel to be processed of the first image is foremost in the screen; and
(c) in response to an instruction of drawing a polygon forming the second image, comparing the Z data recorded in the Z buffer with the Z data of pixel in the polygon, and recording the second image data of the polygon at a corresponding position in the frame buffer, when the pixel in the polygon is foremost in the screen.
The above-described objects can be also achieved by a storage device recording a program for instructing a computer to execute the above-described image processing method.